package com.jason.www.state_pattern.demo2;


import com.jason.www.state_pattern.demo2.context.ATMContext;

public class ATMTest {

    public static void main(String[] args) {
        try {
            test(1000, 500, 200, "123");
            System.out.println("-------");
            test(1000, 300, 500, "123");
            System.out.println("-------");
            test(0, 500, 200, "123");
        } catch (Exception e) {
            System.out.println("机器故障，维修请求已经发送至维修方");
        }
    }


    private static void test(int totalAmount, int balance, int amount, String pwd)throws Exception{
        //创建ATM
        ATMContext atm;
        atm = new ATMContext(totalAmount, balance, amount, pwd);
        //输出初始状态
        System.out.println(atm.toString());
        atm.insertCard();
        atm.submitPwd();
        atm.getCash();
        //输出结束状态
        System.out.println(atm.toString());
    }
}
